package com.iss.controller.room;

import com.google.gson.Gson;
import com.iss.model.Room;
import com.iss.service.RoomService;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

@WebServlet(urlPatterns = "/room/list")
public class ListController extends HttpServlet {
    private RoomService service = new RoomService();
    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

    }

    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

        Gson gson = new Gson();

        List<Room> list = service.getList();

        response.getWriter().println(gson.toJson(list));

    }
}
